package com.requestfactory.wire.spi;

import java.io.Serializable;

public final class WireSPIRequest implements Serializable {
	
	private static final long serialVersionUID = 20080913183807L;
	
	private final String className; 
	private final String methodName;
	private final Class<?>[] parameterTypes;
	private final Serializable[] arguments;
	
	public WireSPIRequest(
			String className,
			String methodName,
			Class<?>[] parameterTypes,
			Serializable[] arguments) {
		assert className  != null && !className.isEmpty();
		assert methodName != null && !methodName.isEmpty();
		assert parameterTypes != null;
		assert arguments  != null;
		this.className  = className;
		this.methodName = methodName;
		this.parameterTypes = new Class[parameterTypes.length];
		System.arraycopy(parameterTypes, 0, 
				this.parameterTypes, 0, parameterTypes.length);
		this.arguments  = new Serializable[arguments.length];
		System.arraycopy(arguments, 0, this.arguments, 0, arguments.length);
	}

	public String getClassName() {
		return className;
	}

	public String getMethodName() {
		return methodName;
	}

	public Class<?>[] getParameterTypes() {
		Class<?>[] parameterTypes = new Class[this.parameterTypes.length];
		System.arraycopy(this.parameterTypes, 0, 
				parameterTypes, 0, this.parameterTypes.length);
		return parameterTypes;
	}

	public Serializable[] getArguments() {
		Serializable[] arguments = new Serializable[this.arguments.length];
		System.arraycopy(this.arguments, 0, 
				arguments, 0, this.arguments.length);
		return arguments;
	}	

}
